// 时间标准化
export const timeFormate = (value, type) => {
  let time = value ? new Date(value) : new Date()
  let year = time.getFullYear()
  let month = (time.getMonth() + 1).toString().padStart(2, '0')
  let day = time
    .getDate()
    .toString()
    .padStart(2, '0')
  let hour = time
    .getHours()
    .toString()
    .padStart(2, '0')
  let min = time
    .getMinutes()
    .toString()
    .padStart(2, '0')
  let weeks = ['周日', '周一', '周二', '周三', '周四', '周五', '周六']
  let dateString = `${year}年${month}月${day}日`
  switch (type) {
    case 'day':
      dateString += ` ${hour}:${min}`
      break
    case 'week':
      dateString += ` ${weeks[time.getDay()]}`
  }
  return dateString
}
// 车票类型标准化
export const ticketTypeFormate = value => {
  let typeText = ['', '日票', '周票', '月票']
  return typeText[value]
}

// 购票列表车票类型
export const recordTypeFormate = value => {
  value = value < 0 ? 0 : value
  let recodeType = ['已取消', '已锁票', '出票中', '已出票']
  return recodeType[value]
}

// 票价过滤器，保留两位小数
export const priceFilters = val => {
  var price = (val / 100).toFixed(2)
  return price
}

// 站台数量过滤器，为0时不显示
export const stationFilters = val => {
  if (val > 0) {
    return val + '站'
  } else {
    return ''
  }
}
